

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gczn_hd/app/core/base/handle_mixin.dart';
import 'package:gczn_hd/app/core/values/App_img.dart';
import 'package:gczn_hd/app/core/values/app_colors.dart';
import 'package:gczn_hd/app/core/values/app_values.dart';
import 'package:gczn_hd/app/core/widget/gczn_card.dart';
import 'package:gczn_hd/app/modules/ppm/station/controllers/station_controller.dart';
import 'package:get/get.dart';

import '../../../../core/values/text_styles.dart';

class ProcessList extends StatelessWidget with HandleMixin{

  final StationController controller = Get.put(StationController());

  @override
  Widget build(BuildContext context) {

    return GcznCard(
      child: Padding(
        padding: EdgeInsets.only(left: AppValues.size36.w, right: AppValues.size36.w,),
        child: Row(
          children: [
            Obx(() => _buildLineSelect() ),
            SizedBox(width: AppValues.size40.w,),
            Expanded(
              flex: 1,
              child: SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                child: Row(
                  children: [1,2,3,4,5,6,7,8,9].map((item) => item == 1 ? _buildProcessProgList() : _buildProcessList()).toList(),
                ),
              )
            ),
            SizedBox(width: AppValues.size40.w,),
            GestureDetector(
              onTap: (){
                showToast("点点点");
              },
              child: Container(
                child: ImageIcon(Image.asset(AppImg.dot).image, size: AppValues.size37.w, color: AppColors.colorWhite,),
              )
            )

          ],
        ),
      ),
    );
  }


  /// 有进度的工序按钮
  Widget _buildProcessProgList(){

    return Container(
      margin: EdgeInsets.only(right: AppValues.size34.w),
      decoration: BoxDecoration(
        border: Border.all(
          color: AppColors.processProgBtn,
          width: 1.0,
        ),
        gradient: const LinearGradient(
          begin: Alignment.centerLeft,
          end: Alignment.centerRight,
          colors: [
            Color.fromRGBO(37, 114, 210, 1),
            Color.fromRGBO(17, 62, 107, 1),
          ],
        ),
        borderRadius: BorderRadius.circular(6.0),
        color: AppColors.processBtn,
        boxShadow: const [pressShadow],
      ),
      child: Stack(
        children: [
          const Positioned(
            top: 0,
            bottom: 0,
            left: 0,
            right: 0,
            child: LinearProgressIndicator(
              value: 0.5, // 假设进度为50%，你可以根据需要动态设置
              backgroundColor: Colors.transparent,
              valueColor: AlwaysStoppedAnimation<Color>(AppColors.gcznPrimaryBlueColorBtn),
            )
          ),
          Align(
              alignment: Alignment.center,
              child: Container(
                padding: EdgeInsets.only(left: AppValues.size26.w, right: AppValues.size26.w, top: AppValues.margin_6.h, bottom: AppValues.margin_6.h),
                child: Text("01工序:注塑", style: submitButtonText.copyWith(fontSize: AppValues.size24.sp)),
              )
          ),
        ],
      ),
    );
  }

 /// 普通工序按钮
  Widget _buildProcessList(){
    
    return Container(
      margin: EdgeInsets.only(right: AppValues.size34.w),
      padding: EdgeInsets.only(left: AppValues.size26.w, right: AppValues.size26.w, top: AppValues.margin_6.h, bottom: AppValues.margin_6.h),
      decoration: BoxDecoration(
        border: Border.all(
          color: const Color.fromRGBO(39, 65, 80, 1),
          width: 1.0,
        ),
        borderRadius: BorderRadius.circular(6.0),
        color: AppColors.processBtn,
        boxShadow: const [pressShadow],
      ),
      child: Text("01工序:注塑", style: submitButtonText.copyWith(fontSize: AppValues.size24.sp, fontWeight: FontWeight.w700),),
    );
    
  }


  Widget _buildLineSelect(){

    return DropdownButton(
      value: controller.select.value,
      padding: EdgeInsets.zero,
      underline: Container(height: 0,),
      icon: const Icon(Icons.keyboard_arrow_down_rounded, color: AppColors.colorWhite,),
      iconSize: AppValues.size32.w,
      style:  submitButtonText.copyWith(fontSize: AppValues.size24.sp),
      items: controller.lines.map<DropdownMenuItem<String>>((String value) {
        return DropdownMenuItem<String>(
          value: value,
          child: Text(value),
        );
      }).toList(),
      onChanged: (String? newValue){
        controller.select.value = newValue!;
      },
      dropdownColor: AppColors.gcznPrimaryBlueBg,
    );
  }

}